<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>首页</title>
    <link href="/static/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
    <th:block th:replace="common/common :: baseJsCss"/>
    <script>
        var SYS_BASE_URL_ENUM;
    </script>
    <style>
        /* 通用 */
        .layui-card {
            height: 100%;
            overflow: hidden;
        }

        .layui-card-body {
            line-height: 24px !important;
        }

        html {
            color: #666666;
        }

        .shadow {
            box-shadow: 1px 1px 10px rgba(0, 0, 0, .2);
            border-radius: 20px;
            overflow: hidden;
        }

        .layui-card-header {
            display: flex;
            align-items: center;
            color: #000;
            font-weight: bold;
        }

        .title-border {
            display: inline-block;
            border-left: 3px solid #009688;
            height: 1em;
            margin-right: 10px;
        }

        .content-header {
            color: #333;
        }

        .content-body {
            color: #888888;
            font-size: .9em;
        }

        /* 第一行 */
        .first-row > div {
            min-height: 390px;
        }

        /* 公司业务 */
        img {
            padding: 0 !important;
        }

        /* 新闻 */
        .news {
            font-size: .9em;
        }

        .news-item {
            border-bottom: 1px solid #f5f5f5;
            padding: 10px 0;
        }

        .news-item:last-child {
            border: none;
        }

        .news-red {
            color: red;
        }

        /* 第2行 */
        .second-row > div {
            min-height: 380px;
        }
    </style>
</head>
<body>
<div class="layui-fluid bg-light">
    <!-- 业务新闻 -->
    <div class="layui-row layui-col-space10 first-row">
        <!-- 公司业务 -->
        <div class="layui-col-sm8 layui-col-xs12"
             style="max-width: 1120px;">
            <div class="layui-card"
                 style="height: 390px;">
                <div class="layui-card-header"><span class="title-border"></span> 公告栏</div>
                <div class="layui-card-body" style="overflow-y: auto;height: 350px;text-align: center;display: none;"
                     id="noneNotice">
                    <div style="margin-top: 80px">
                        <img class="pl-2" style="min-width:184px;" src="/static/home/images/pic_bg.png">
                        <p>暂无公告</p>
                    </div>

                </div>
                <div id="staffNotice" class="layui-card-body"
                     style="overflow-y: scroll;height: 350px;font-size: 13px;color: #888888">

                </div>
            </div>
        </div>


        <!-- 标准库 -->
        <div class="layui-col-sm4 layui-col-xs12" style="max-width: 540px;">
            <div class="layui-card" style="height: 390px;overflow-y: auto">
                <div class="layui-form-item">
                    <div class="layui-card-header" style="position: relative">
                        <span class="title-border"></span>标准库
                        <h4 style="position: absolute;right: 40px">
                            <a id="standardManageBtn"
                               th:if="${#authPermit.checkMenuPermits(false, '/standard/record/list.action')}"
                               lay-text="标准管理" lay-href="/standard/record/list.action">标准管理>></a>
                        </h4>
                    </div>
                </div>

                <div class="layui-card-body px-4" style="font-size: .9em;" id="standardDiv">

                </div>
                <div class="layui-card-body px-4" style="font-size: .9em;display: none" id="moreDiv">
                    <div class="news-item"
                         style="text-align: right; margin-right: 10px;padding-bottom: 0.18rem !important;padding-top: 0.20rem !important">
                        <div class="layui-btn-group">
                            <a id="viewMoreStandardBtn" class="layui-btn layui-btn-sm layui-btn-primary" lay-text="查看标准"
                               lay-href="/standard/record/checkList.action">
                                点击查看更多标准
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- 特性 下载 -->
    <div class="layui-row layui-col-space10 second-row">
        <!-- 系统特性 -->
        <div class="layui-col-sm12">
            <div class="layui-card"
                 style="min-height: 380px;">
                <div class="layui-card-header"><span class="title-border"></span> 公司业务</div>
                <div class="layui-card-body">
                    <!-- logo-介绍 -->
                    <div class="layui-row d-flex" style="background-color:#F1F2F4;">
                        <!-- logo -->
                        <div style="min-width:400px;padding: 0 !important"
                             class="logo  layui-col-sm5 layui-col-xs12 d-flex  py-5 px-4">
                            <img class="pl-2" style="min-width:184px;" src="/static/home/images/pic_logo.png">
                        </div>
                        <!-- 说明 -->
                        <div class="layui-col-xs12 layui-col-sm6" style="margin-left: 30px;margin-top: 30px;">
                            <strong class="content-header"> 关于啄木鸟 </strong>
                            <p class="content-body">
                                啄木鸟维修，始创于1995年，总部位于“山城”重庆，在北京、上海、深圳、广州等城市
                                <br>
                                设有33家直营子公司，服务覆盖全国近五百个县级以上城市。啄木鸟维修以家庭和企业
                                维修为主营业务方向，提供维修、清洗、保养、管道疏通及开锁换锁等服务。
                            </p>
                        </div>
                    </div>
                    <!-- 2个维修 -->
                    <div style="background-color:#F1F2F4;margin-top: 10px"
                         class="layui-row d-flex align-items-center justify-content-space border-top">
                        <div class="layui-col-sm5 layui-col-xs12 d-flex align-items-center mr-3">
                            <img
                                    class="mr-3"
                                    style="max-width: 150px;"
                                    src="/static/home/images/pic_jiating_2x.png"
                                    alt=""
                            >
                            <div class="content layui-col-sm8 layui-col-xs12">
                                <strong class="content-header">家庭维修</strong>
                                <div class="content-body">
                                    啄木鸟家庭维修以围绕家电、家居生活为主营业务方向，是
                                    提供以维修、清洗、保养、置换回收的家电服务为主，家居
                                    家具维修保养、家庭水电、开锁换锁等为辅的全国连锁直营
                                    家庭维保服务企业。
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-sm6 layui-col-xs12 d-flex align-items-center">
                            <img
                                    class="mr-3"
                                    style="max-width: 150px;"
                                    src="/static/home/images/pic_qiye_2x.png"
                                    alt=""
                            >
                            <div class="content layui-col-sm8 layui-col-xs12">
                                <strong class="content-header">
                                    企业维修
                                </strong>
                                <div class="content-body">
                                    啄木鸟企业维修以中央空调维保、工控维修、酒店和公寓维
                                    保为主营业务拓展方向，首推中央空调及企业包年买断维修
                                    业务模式和企业VIP会员充值消费模式，力求解决企业型客户
                                    多场景的维保难题。
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- 资料下载 -->
    </div>
</div>
<script type="application/javascript">
    layui.config({
        base: "/static/lay/"
    }).extend({
        index: "lib/index"
    }).use(['index', 'zmnApp'], function () {
        var $ = layui.$;
        let zmnApp = layui.zmnApp;
        let zmnAppBaseUrl = zmnApp.getBaseUrl('[[${ZMN_URL_ENV}]]');
        $('#noneNotice').hide();
        $('#staffNotice').show();

        $("#standardManageBtn").attr("lay-href", zmnAppBaseUrl + $("#standardManageBtn").attr("lay-href"));
        $("#viewMoreStandardBtn").attr("lay-href", zmnAppBaseUrl + $("#viewMoreStandardBtn").attr("lay-href"));

        /**
         * 消息通知
         *
         * crossDomain: 跨域
         * xhrFields: 带 Cookie
         */
        // let readMsg = function() {
        //     let baseUrl = "https://api-push.xiujiadian.com";
        //     if (/.+dev-plat.xiujiadian.com.*/.test(window.location.href)) {
        //         baseUrl = "http://dev-api-push.xiujiadian.com";
        //     } else if (/.+test-plat.xiujiadian.com.*/.test(window.location.href)) {
        //         baseUrl = "https://test-api-push.xiujiadian.com";
        //     }
        //
        //     $.ajax({
        //         type: "GET",
        //         url: baseUrl + "/push/inner/getOne",
        //         crossDomain: true,
        //         dataType: 'json',
        //         xhrFields: {withCredentials: true},
        //         async: true,
        //         timeout: 1000,
        //         success: function (data) {
        //             if (data.statusBool) {
        //                 console.log("站内信：读取到一条消息，头层展示");
        //                 open(data.data);
        //             } else {
        //                 setTimeout(readMsg, waitTime);
        //             }
        //         }
        //     });
        // }

        // let open = function(inner) {
        //     var businessData = JSON.parse(inner.businessData);
        //     var btn = "<a lay-href='url'>【name】</a>";
        //
        //     if (businessData != null) {
        //         var url = businessData.linkUrl;
        //         var name = businessData.linkName;
        //
        //         btn = btn.replace("url", url);
        //         btn = btn.replace("name", name == null ? "查看" : name);
        //     } else {
        //         btn = "";
        //     }
        //
        //     top.layer.open({
        //         id: 'PUSH_MSG'
        //         , title: '信息'
        //         , content: inner.content + btn
        //         , shade: 0
        //         , offset: 'rb'
        //         , btn: ['已读', '暂存']
        //         , yes: function (index, layero) {
        //             read(inner.id);
        //             setTimeout(readMsg, waitTime);
        //             layer.close(index);
        //         }, btn2: function (index, layero) {
        //             setTimeout(readMsg, waitTime + addTime);
        //             layer.close(index);
        //         }, cancel: function (index) {
        //             setTimeout(readMsg, waitTime + addTime);
        //             layer.close(index);
        //         }
        //     });
        // }
        //
        // let read = function(id) {
        //     let baseUrl = "https://api-push.xiujiadian.com";
        //     if (/.+dev-plat.xiujiadian.com.*/.test(window.location.href)) {
        //         baseUrl = "http://dev-api-push.xiujiadian.com";
        //     } else if (/.+test-plat.xiujiadian.com.*/.test(window.location.href)) {
        //         baseUrl = "https://test-api-push.xiujiadian.com";
        //     }
        //
        //     $.ajax({
        //         type: "GET",
        //         url: baseUrl + "/push/inner/read?id=" + id,
        //         crossDomain: true,
        //         dataType: 'json',
        //         xhrFields: {withCredentials: true},
        //         async: false
        //     });
        // }
        //
        // var waitTime = 10 * 1000;
        // var addTime = 60 * 1000;
        // readMsg();
        console.log("主页加载。。")

        $.get('/standard/record/listAjax.action', {}, function (resp) {
            resp.data.forEach(item => {
                item.createTime = new Date(item.createTime).format("yyyy-MM-dd hh:mm:ss");
                item.title = (item.title.length > 15 ? item.title.substr(0, 14) + '...' : item.title) + item.version;
                let html = `<div class="news-item" style="padding-bottom: 0.18rem !important;padding-top: 0.20rem !important">
                                        <a lay-text="查看标准" lay-href="` + zmnAppBaseUrl + `/standard/record/preview.action?standardId=${item.standardId}&flag=2">
                                            <div class="layui-row">
                                                <div class="layui-col-md8">
                                                    ${item.title}
                                                </div>
                                                <div class="layui-col-md4">
                                                    ${item.createTime}
                                                </div>
                                            </div>
                                        </a>
                                    </div>`;
                $("#standardDiv").append(html);
            });
            if (resp.data.length > 7) {
                $("#moreDiv").show();
            }
        });

        $.get('/notice/getStaffNotice.action', {}, function (resp) {
            if (zmnUtil.isEmptyNull(resp.data.content)) {
                $('#noneNotice').show();
                $('#staffNotice').hide();
            } else {
                $('#staffNotice').html(resp.data.content.replace(/[\r\n]/g, "<br>"));
                $('#noneNotice').hide();
                $('#staffNotice').show();
            }
        });

        //扩展Date的format方法
        Date.prototype.format = function (format) {
            var o = {
                "M+": this.getMonth() + 1,
                "d+": this.getDate(),
                "h+": this.getHours(),
                "m+": this.getMinutes(),
                "s+": this.getSeconds(),
                "q+": Math.floor((this.getMonth() + 3) / 3),
                "S": this.getMilliseconds()
            };
            if (/(y+)/.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            }
            for (var k in o) {
                if (new RegExp("(" + k + ")").test(format)) {
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
                }
            }
            return format;
        };
    });

</script>

</body>
</html>